'''
Created on Feb 23, 2011

@author: Bogdan Mata
'''

def sort(list):
    newList = []
    if list:
        for i in list:
            newList.append(i)
    flag = True
    while flag:
        flag = False
        i = 0
        while i < len(newList) - 1:
            if newList[i] > newList[i + 1]:
                aux = newList[i]
                newList[i] = newList[i + 1]
                newList[i + 1] = aux
            i += 1
    return newList

print("Type integers, each followed by Enter; or just Enter to finish")
sum = 0
lowest = None
highest = None
count = 0
numbers = []
median = None
while True:
    line = input("enter a number or Enter to finish: ")
    if line:
        try:
            number = int(line)
        except ValueError as err:
            print(err)
            continue
        numbers += [number]
        sum += number
        if lowest is None or lowest > number:
            lowest = number
        if highest is None or highest < number:
            highest = number
        count += 1
    else:
        break
if count:
    print(numbers)
    numbers = sort(numbers)
    if count % 2 == 0:
        median = (numbers[int(count/2) - 1] + numbers[int(count/2)]) / 2
    else:
        median = numbers[int(count/2)]
    
    print("count =", count, "sum =", sum, "lowest = ", lowest, "highest = ", highest, "mean =", sum / count, "median = ", median)
    

